//
//  HelpCenterViewController.m
//  EarnCommision
//
//  Created by EvanZ on 15/3/15.
//  Copyright (c) 2015年 EC. All rights reserved.
//

#import "HelpCenterViewController.h"
#import "IIViewDeckController.h"



@interface HelpCenterViewController (){
    NSMutableArray * m_itemArray;
}

@end

@implementation HelpCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc]initWithTitle:@"open" style:UIBarButtonItemStylePlain target:self action:@selector(openLeftDeck)];
    self.navigationItem.leftBarButtonItem = leftButton;
    
    NSDictionary * dic1 = [[NSDictionary alloc]initWithObjectsAndKeys:@"aa",@"name", nil];
    NSDictionary * dic2 = [[NSDictionary alloc]initWithObjectsAndKeys:@"aa",@"name", nil];
    NSDictionary * dic3 = [[NSDictionary alloc]initWithObjectsAndKeys:@"aa",@"name", nil];
    NSDictionary * dic4 = [[NSDictionary alloc]initWithObjectsAndKeys:@"aa",@"name", nil];
    
    m_itemArray = [[NSMutableArray alloc]initWithObjects:dic1,dic2,dic3,dic4, nil];
    
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)openLeftDeck{
    [self.viewDeckController toggleLeftViewAnimated:YES];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return [m_itemArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary * dataDic = [m_itemArray objectAtIndex:indexPath.row];
    
    MyCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if (cell == nil) {
        cell = [[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
    }
    cell.m_titleLabel.text = [dataDic valueForKey:@"name"];
    [cell setImageView:[UIImage imageNamed:[NSString stringWithFormat:@"personal_center_icon_%d",indexPath.row]]];
    
    return cell;
}

@end

@implementation MyCell
@synthesize m_titleLabel;
@synthesize m_imageView;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        m_titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 10, 300, 20)];
        [m_titleLabel setFont:[UIFont boldSystemFontOfSize:16]];
        [m_titleLabel setBackgroundColor:[UIColor clearColor]];
        [self addSubview:m_titleLabel];
        
        m_imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 30, 30)];
        [self addSubview:m_imageView];
        
        //        UIView * backColorView = [[UIView alloc]initWithFrame:CGRectMake(0, 240, self.frame.size.width, 15)];
        //        [backColorView setBackgroundColor:[UIColor colorWithRed:239.0/255.0 green:239.0/255.0 blue:244.0/255.0 alpha:1.0]];
        //        [self addSubview:backColorView];
        
        //        UIView * backLineView = [[UIView alloc]initWithFrame:CGRectMake(0, 240, self.frame.size.width, 1)];
        //        [backLineView setBackgroundColor:[UIColor colorWithRed:229.0/255.0 green:229.0/255.0 blue:234.0/255.0 alpha:1.0]];
        //        [self addSubview:backLineView];
        
        self.selectionStyle = UITableViewCellSelectionStyleGray;
    }
    return self;
}

- (void)setImageView:(UIImage*)image
{
    m_imageView.image = image;
    [m_imageView setFrame:CGRectMake(10, 10, 30 , 30)];
}

- (void)setImageUrl:(NSString *)urlStr{
    //NSURL * url = [NSURL URLWithString:[[BASED_URL stringByAppendingString:@"/"] stringByAppendingString:urlStr]];
    //[m_imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"food_loading"]];
}


@end
